Code sample Home

Draw custom raster image (rendered by application)
...
  // register event procedure
  lcEventSetProc( LC_EVENT_DRAWIMAGE, DrawImageProc, 0, 0 );
...

  // create image object in a drawing
  HANDLE hImgRef;
  hImgRef = lcBlockAddImagePlace( hBlock, 105, 10,20,100,50, true );
  lcBlockUpdate( hBlock, false, hImgRef );
  lcWndRedraw( m_hLcWnd ); 
...

// This function is called on LC_EVENT_DRAWIMAGE event
//-----------------------------------------------
void CALLBACK DrawImageProc (HANDLE hEvent)
{
  COkDib Dib;
  OK_DIBDRAWPRM Prm;
  double W, H, PixelSize;
  int    idImage;
  HANDLE hLcWnd;

  if (Dib.Load( L"d:/Pictures/SomeImage.bmp" ) == false){
    return;
  }
  hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );
  idImage = lcPropGetInt( hEvent, LC_PROP_EVENT_INT6 );  // ID passed by lcBlockAddImagePlace()
  W = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );    // image width (drawing's units)
  H = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );    // image height (drawing's units)
  memset( &Prm, 0, sizeof(Prm) );
  Prm.hDC = (HDC)lcPropGetHandle( hEvent, LC_PROP_EVENT_HDC );
  Prm.ImgLeft   = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );
  Prm.ImgBottom = lcPropGetInt( hEvent, LC_PROP_EVENT_INT2 );
  PixelSize = lcPropGetFloat( hLcWnd, LC_PROP_WND_PIXELSIZE );
  Prm.ImgWidth  = (UINT)(W/PixelSize + 0.5);  // 0 for non-scalable image
  Prm.ImgHeight = (UINT)(H/PixelSize + 0.5);  // 0 for non-scalable image
//  Prm.Align = 1;          // alignment for non-scalable image, 0: center, 1: left-bottom
  Prm.bDevRectValid = true;   // if TRUE then a device rectangle (below parameters) are valid
  Prm.DevLeft   = 0;
  Prm.DevTop    = 0;
  Prm.DevRight  = lcPropGetInt( hEvent, LC_PROP_EVENT_INT3 );
  Prm.DevBottom = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 );
  // the next function draws the image using WinAPI function StretchDIBits
  Dib.Draw( Prm ); 
}